// 设置订单列表
const setOrderList = (state, orderList) => {
	console.log(orderList)
	if(orderList == '') {
		return
	}
	//	console.log(orderList.length)
	for(var i = 0; i < orderList.length; i++) {
		for(var j = 0; j < orderList[i].length; j++) {
			var currentItem = orderList[i][j];
			// 判断商品类型
			switch(currentItem.order_label) {
				case "0":
					currentItem.order_label_text = null;
					break;
				case "1":
					currentItem.order_label_text = "月定制";
					break;
				case "2":
					currentItem.order_label_text = "拼团";
					break;
				case "3":
					currentItem.order_label_text = "众筹";
					break;
			}
			// 判断订单的状态
			switch(currentItem.order_state) {
				case 0:
					currentItem.order_state_text = '已取消';
					if(currentItem.order_label == 0 || currentItem.order_label == 1 || currentItem.order_label == 2 || currentItem.order_label == 3) {
						currentItem.url = "/goodsToPay/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					} else {
						currentItem.url = "/activityToPay/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					break;
				case 10:
					currentItem.order_state_text = "去支付";
					currentItem.cancel_state_text = "取消订单";
					if(currentItem.order_label == 0 || currentItem.order_label == 1 || currentItem.order_label == 2 || currentItem.order_label == 3) {
						currentItem.url = "/goodsToPay/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					} else {
						currentItem.url = "/activityToPay/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					break;
				case 20:
					currentItem.url = "/goodsPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					//展示标签 处理跳转路径  0普通商品 1月定制 2拼团 3众筹 4私人定制 5世界厨房 6官方组局 7美食旅行
					if(currentItem.refund_state == 3) {
						currentItem.order_state_text = '退款中';
					} else if([1, 2, 4].indexOf(currentItem.refund_state) > 0) {
						currentItem.order_state_text = '已退款';
					} else {
						switch(currentItem.order_label) {
							case '0':
								currentItem.url = "/goodsPayed/order_id=" + currentItem.order_id + "/" + currentItem.order_label;
								currentItem.order_state_text = "已付款";
								break;
							case '1':
								currentItem.order_state_text = "已付款";
								break;
							case '2':
								currentItem.order_state_text = "拼团中";
								break;
							case '3':
								currentItem.order_state_text = "众筹中";
								break;
							case '4':
								currentItem.order_state_text = "待参加";
								currentItem.url = "/activityToPay/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
								break;
							default:
								currentItem.order_state_text = "待参加";
								currentItem.url = "/activityPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
								break;
						}
					}

					break;
				case 30:
					if(currentItem.order_label == 0) {
						currentItem.url = "/goodsPayed/order_id=" + currentItem.order_id + "/" + currentItem.order_label;
					} else {
						currentItem.url = "/goodsPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					currentItem.order_state_text = '已发货';
					break;
				case 40:
					currentItem.url = "/goodsPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					if(currentItem.order_label == 0) {
						currentItem.url = "/goodsPayed/order_id=" + currentItem.order_id + "/" + currentItem.order_label;
					}
					currentItem.order_state_text = '已收货';
					break;
				case 50:
					if(currentItem.order_label == 2) {
						currentItem.order_state_text = "待发货";
						currentItem.url = "/goodsPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					break;
				case 60:
					if(currentItem.order_label == 3) {
						currentItem.order_state_text = "众筹成功";
						currentItem.url = "/goodsPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					break;
				case 70:
					if(currentItem.order_label == 5 || currentItem.order_label == 6 || currentItem.order_label == 7) {
						currentItem.order_state_text = '待服务';
						currentItem.url = "/activityPayed/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					break;
				case 90:
					if(currentItem.order_label == 5 || currentItem.order_label == 6 || currentItem.order_label == 7) {
						currentItem.order_state_text = "已付定金";
						currentItem.url = "/activityToPay/all_no=" + currentItem.all_no + "/" + currentItem.order_label;
					}
					break;
			}
			// 整理数据，数据名称不一致
			if(currentItem.order_goods_info.item_image != undefined) {
				currentItem.order_goods_info.goods_image = currentItem.order_goods_info.item_image
				currentItem.order_goods_info.goods_name = currentItem.order_goods_info.item_name;
				currentItem.order_goods_info.goods_num = currentItem.order_goods_info.item_num;
			}
			//			currentItem.jump_url = '/order'
		}
	}
	// 数组倒序一下
	state.orderList = orderList.reverse();

}
// 设置订单详情
const setOrderDetail = (state, orderDetail) => {
	console.log(orderDetail)
	for(var j = 0; j < orderDetail.goods_list.length; j++) {
		// 整理数据，数据名称不一致
		if(orderDetail.goods_list[j].item_image) {
			orderDetail.goods_list[j].goods_image = orderDetail.goods_list[j].item_image
			orderDetail.goods_list[j].goods_num = orderDetail.goods_list[j].item_num
			orderDetail.goods_list[j].goods_name = orderDetail.goods_list[j].item_name
			orderDetail.goods_list[j].goods_price = orderDetail.goods_list[j].item_price
			orderDetail.goods_list[j].goods_spec = orderDetail.goods_list[j].goods_spec
		}
	}

	state.orderDetail = orderDetail
}
export default {
	setOrderList,
	setOrderDetail,
}